package com.google.code.gwtquickstartplugin;

/**
 * Represents a &lt;servlet&gt; entry in a <code>&lt;Module&gt;</code>.gwt.xml
 * file.
 *
 * @author Carlos D. Morales
 */
public class RemoteServiceDescription implements Servlet {
    private String path;

    private String moduleFqn;

    public String getUrl() {
        return getPath();
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getClassName() {
        return moduleFqn;
    }

    public void setModuleFqn(String moduleFqn) {
        this.moduleFqn = moduleFqn;
    }

    public String getModuleName() {
        if (moduleFqn == null) {
            return null;
        }
        int lastPeriod = moduleFqn.lastIndexOf('.');
        String moduleName = moduleFqn;
        if (lastPeriod != -1 && lastPeriod < moduleFqn.length() - 1) {
            moduleName = moduleFqn.substring(lastPeriod + 1);
        }

        return moduleName;
    }
}
